package com.hust.bridgecheck.repository;

import com.hust.bridgecheck.entity.Bridge;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface BridgeRepository extends JpaRepository<Bridge,Integer> {
    //获取所有桥和相关的地区
    @Query(nativeQuery = true,value = "select b.id,b.domainid,b.health,b.length,b.name,b.span,b.type,b.use_years,d.domain_name from bridge b,domain d where b.domainid = d.domainid order by d.domainid")//JPQL方法
           public List<Object> getAllBridgeDomain();

    @Query(nativeQuery = true,value = "select b.id,b.domainid,b.health,b.length,b.name,b.span,b.type,b.use_years,d.domain_name from bridge b,domain d where b.domainid = d.domainid and b.domainid = ?1")//JPQL方法
        public List<Object> getDomainBridge(Integer domainid);

    @Query(nativeQuery = true,value = "select b.id,b.domainid,b.health,b.length,b.name,b.span,b.type,b.use_years,d.domain_name from bridge b,domain d where b.domainid = d.domainid and b.Name = ?1")
        public List<Object> getBridgeByName(String bridge);
}
